///<reference path="hero.ts"/>
import { Injectable } from '@angular/core';
import {HEROES} from "./moke-hero";
import {Hero} from "./hero";

@Injectable()
export class HeroService {

  constructor() { }
  getHeros(): Promise<Hero[]>{
    return Promise.resolve(HEROES);
  }
  getHeroById(id: number):Promise<Hero>{
    return this.getHeros().then(heros=>heros.find(hero=>hero.id == id));
  }
}
